﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Printing;
using System.Windows.Forms;


namespace Shared
{
    public class PrintRoute
    {
       
        public string stringToPrint { get; set; }
        public PrintRoute()
        {
 
        }
        
        public void DoPrint()
        {
            PrintPreviewDialog dlgPreview = new PrintPreviewDialog();
            PrintDocument recordDoc;
            // Create the document and name it
            recordDoc= new PrintDocument();
            recordDoc.DocumentName = "Route";
            recordDoc.PrintPage += new PrintPageEventHandler(this.PrintReceiptPage);
            
            // Preview document
          //  dlgPreview.ShowDialog();
            
            //print document
            recordDoc.Print();            
            
            // Dispose of document when done printing
            recordDoc.Dispose();
       }

        private void PrintReceiptPage(object sender, PrintPageEventArgs e)
        {
            int y;
            // Print receipt
            Font myFont = new Font("Times New Roman", 12, FontStyle.Bold);
            y = e.MarginBounds.Y;
            e.Graphics.DrawString(stringToPrint , myFont, Brushes.Black, e.MarginBounds.X, y);
        }
    }
}




